#include "eventloop.h"
#include "event.h"

EventLoop::EventLoop(Object *parent) : Object(parent)
{
    _running = false;
}

EventLoop::~EventLoop()
{}

int EventLoop::exec()
{
    _running = true;

    while (_running)
    {
        while (_events.size()>0)
        {
            _events[0]->processEvent();
            _events.erase(_events.begin());
        }
    }

    return 0;
}

void EventLoop::quit()
{
}

const std::vector<Event*>& EventLoop::events() const
{
    return _events;
}

std::vector<Event*>& EventLoop::events()
{
    return _events;
}

